<!-- Yandex Maps -->
<script src="http://api-maps.yandex.ru/2.0/?load=package.full&amp;lang=ru-RU" type="text/javascript"></script>

<!-- Codeeditor -->
<script src="<?= URL::site('static/administration/js/codemirror/lib/codemirror.js') ?>"></script>
<script src="<?= URL::site('static/administration/js/codemirror/mode/javascript/javascript.js') ?>"></script>
<link rel="stylesheet" href="<?= URL::site('static/administration/js/codemirror/lib/codemirror.css') ?>">
<link rel="stylesheet" href="<?= URL::site('static/administration/js/codemirror/theme/ambiance.css') ?>">
<style>.CodeMirror { height: 500px }</style>

<div class="form-actions content-header">
	<h1 class="pull-left"><?= $title ?></h1>
</div>
<?= Form::open('administration/Asettings/'.$_key.'/save', array('method' => 'post', 'enctype' => 'multipart/form-data', 'class' => 'form-horizontal')) ?>
	<? foreach ($settings as $key => $item): ?>
		<?= $item['type'] == 'yandexmap' ? Model::factory('Afunctions')->yandex_map_init($item['value']) : '' ?>
		<div class="control-group">
			<label class="control-label" for="account_<?= $item['key'] ?>"><?= $item['hint'] ?></label>
			<div class="controls">
				<? if ($item['type'] == 'text'): ?>
					<?= Form::input($item['key'], $item['value'], array('id' => 'account_'.$item['key'], 'placeholder' => $item['hint'], 'class' => 'span3')); ?>
				<? elseif ($item['type'] == 'textarea'): ?>
					<?= Form::textarea($item['key'], $item['value'], array('id' => 'account_'.$item['key'], 'placeholder' => $item['hint'], 'class' => 'span3', 'rows' => '5')) ?>
				<? elseif ($item['type'] == 'codeeditor'): ?>
					<textarea name="<?= $item['key'] ?>" id="codeeditor_<?= $item['key'] ?>" cols="30" rows="10"><?= $item['value'] ?></textarea>
					<script>
						var myCodeMirror = CodeMirror.fromTextArea(codeeditor_<?= $item['key'] ?>, {
    						lineNumbers: true,
    						theme: 'ambiance'
  						});
					</script>
				<? elseif ($item['type'] == 'password'): ?>
					<?= Form::password($item['key'], '', array('id' => 'account_'.$item['key'], 'placeholder' => $item['hint'], 'class' => 'span3')); ?>
				<? elseif ($item['type'] == 'yandexmap'): ?>
					<div id="map" style="width:600px; height:300px"></div>
					<input type="hidden" name="coordinates" value="<?= $item['value'] ?>" />
				<? elseif ($item['type'] == 'image'): ?>
					<?= Form::file($item['key']) ?>
				<? endif ?>
			</div>
		</div>
	<? endforeach ?>
	<div class="control-group">
		<label class="control-label"></label>
		<div class="controls">
			<button type="submit" class="btn">Сохранить</button>
		</div>
	</div>
<?= Form::close() ?>